#include "_ftp.h"
#include <iostream>
using namespace std;

Cftp ftp;

int main(int argc, char *argv[]){
    // 登录
    if(ftp.login("192.168.199.128:21", "ly", "1111") == false){
        cout << "ftp.login(192.168.199.128:21) failed." << endl;
        return -1;
    }
    cout << "ftp.login(192.168.199.128:21 success." << endl;

    // 查看文件时间
    if(ftp.mtime("/home/ly/Documents/prog.c") == false){
        cout << "ftp.mtime(/home/ly/Documents/prog.c) failed." << endl;
        return -1;
    }
    cout << "ftp.mtime(/home/ly/Documents/prog.c) success, mtime = " << ftp.m_mtime << "." << endl;
    
    // 查看文件大小
    if(ftp.size("/home/ly/Documents/prog.c") == false){
        cout << "ftp.size(/home/ly/Documents/prog.c) failed." << endl;
        return -1;
    }
    cout << "ftp.size(/home/ly/Documents/prog.c) success, size = " << ftp.m_size << "." << endl;

    // 查看文件列表
    if(ftp.nlist("/home/ly/Documents", "/tmp/idc/test.lst") == false){
        cout << "ftp.nlist(/home/ly/Documents, /tmp/idc/test.lst) failed." << endl;
        return -1;
    }
    cout << "ftp.nlist(/home/ly/Documents, /tmp/idc/test.lst) success." << endl;


    // 下载
    if(ftp.get("/home/ly/Documents/prog.c", "/tmp/idc/prog.c.bak", true) == false){
        cout << "ftp.get() failed." << endl;
        return -1;
    }
    cout << "ftp.get() success." << endl;

    // 上传
    if(ftp.put("/home/ly/Documents/prog.c", "/home/ly/Documents/prog.cpp.bak", true) == false){
        cout << "ftp.put() failed." << endl;
        return -1;
    }
    cout << "ftp.put() success." << endl;

    // 登出
    ftp.logout();

    return 0;
}